package com.wordpress.standal.multimethod.examples.gridwalk

import com.wordpress.standal.multimethod.api.value2.MultiMethod

object GridWalkPermutations {
  
  def main(args : Array[String]) : Unit = {
    
    val calculate = MultiMethod[Int, Int, Int]
    
    calculate.add(1, classOf[Int], (n: Int, m: Int) => m+1)
    calculate.add(classOf[Int], 1, (n: Int, m: Int) => n+1)
    calculate.add(classOf[Int], classOf[Int], (n: Int, m: Int) => calculate(n-1, m) + calculate(n, m-1))

    val n = 4
    val m = 3
    val perm = calculate(n, m)
    
    println("#permutations for " + n + " x " + m + " = " + perm)
    
  }

}
